package fatworm.query;

import fatworm.storage.table.*;
import fatworm.tx.Transaction;
import fatworm.query.constant.Constant;

public class TableScan implements UpdateScan {
	
	private HeapFile hf;
	private Schema sch;
	
	public TableScan(TableInfo ti, Transaction tx) {
		hf = new HeapFile(ti, tx);
		sch = ti.schema();
	}
	
	public void beforeFirst() {
		hf.beforeFirst();
	}
	
	public boolean next() {
		return hf.next();
	}
	
	public void close() {
		hf.close();
	}
	
	public Constant getVal(String name) {
		return hf.getValue(name);
	}
	
/*	public int getInt(String name) {
		return hf.getInt(name);
	}
	
	public String getString(String name) {
		return hf.getString(name);
	}*/
	
	public boolean hasField(String name) {
		return sch.hasField(name);
	}
	
	public void setVal(String name, Constant val) {
		hf.setValue(name, val);
	}
	
/*	public void setInt(String name, int val) {
		hf.setInt(name, val);
	}
	
	public void setString(String name, String val) {
		hf.setString(name, val);
	}*/
	
	public void insert() {
		hf.insert();
	}
	
	public void delete() {
		hf.delete();
	}
	
	public RID getRID() {
		return hf.currentRid();
	}
	
	public void moveToRID(RID rid) {
		hf.moveToRid(rid);
	}
}